﻿Imports System.Net.Mail
Imports System.Net
Public Class Form1
    Dim arrayWeb As New List(Of WebBrowser)
    Dim arrayPages As New List(Of TabPage)
    Dim ControlloWeb As WebBrowser
    Dim PaginaScheda As TabPage
    Public Function CreaControlloWeb()
        ControlloWeb = New WebBrowser
        arrayWeb.Add(ControlloWeb)
        ControlloWeb.Dock = DockStyle.Fill
        PaginaScheda = New TabPage
        arrayPages.Add(PaginaScheda)
        TabControl1.TabPages.Add(PaginaScheda)
        PaginaScheda.Controls.Add(ControlloWeb)
        PaginaScheda.Text = "Nuova scheda"
        TabControl1.SelectedTab = PaginaScheda
        PaginaScheda.Text = "" + ControlloWeb.DocumentTitle
    End Function
    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        ProgressBar1.Value = 0
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoPage.Click
        WebBrowser1.Navigate(TextBox1.Text)
    End Sub

    Private Sub WebBrowser1_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
        Dim CurProg As Double
        Dim MaxProg As Double
        CurProg = e.CurrentProgress
        MaxProg = e.MaximumProgress
        ProgressBar1.Value = (CurProg / MaxProg) * 100
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        CreaControlloWeb()
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub PictureBox1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles reload_button.Click

        WebBrowser1.Refresh()
    End Sub

    Private Sub Home_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Home.Click
        WebBrowser1.Navigate(TextBox2.Text)
    End Sub

    Private Sub PictureBox1_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Forward.Click
        WebBrowser1.GoForward()
    End Sub

    Private Sub Backward_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Backward.MouseClick
        WebBrowser1.GoBack()
    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If (e.KeyChar = vbCr) Then
            WebBrowser1.Navigate(TextBox1.Text)
        End If
    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim reteDisponibile As Boolean
        reteDisponibile = My.Computer.Network.IsAvailable
        If reteDisponibile = True Then
            MsgBox("La rete è disponibile")
        Else
            MsgBox("La rete NON è disponibile")
        End If
    End Sub

    Private Sub timerstart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerstart.Click
        timerreload.Start()
    End Sub

    Private Sub timerstop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerstop.Click
        timerreload.Stop()
    End Sub

    Private Sub timerreload_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerreload.Tick
        WebBrowser1.Refresh()
    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Info_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Info.Click
        Dim frm As New AboutBox1()
        frm.ShowDialog()
    End Sub
End Class
